package com.h3bpm.web.instance.consultingOutcomeDocument.dao.Impl;

import com.h3bpm.web.common.controller.InstancesController;
import com.h3bpm.web.instance.consultingOutcomeDocument.dao.MagnitudeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author villwang
 * @date 2020/07/21
 **/
@Repository
public class MagnitudeServiceImpl implements MagnitudeService {
    private static Logger logger = LoggerFactory.getLogger(MagnitudeServiceImpl.class);

    @Autowired
    private JdbcTemplate primaryJdbcTemplate;
    @Override
    public Map<String, Object> getMagnitude(String deptId) {

        String sql="SELECT leader_no as departmentManager,what_business_leader_no as technicalDirector \n" +
                ",dept_short_name as shortName,dict_label as labelName  FROM sys_dept d\n" +
                "LEFT JOIN \n" +
                "(SELECT dict_value,dict_label FROM sys_dict_data where dict_type ='tjec_what_business') sdd on d.what_business = sdd.dict_value\n" +
                "WHERE d.guid='"+deptId+"'";
        List<Map<String, Object>> projectList = primaryJdbcTemplate.queryForList(sql);
        logger.info("业务系统部门返回值_________-"+projectList);
        if(projectList.isEmpty()||projectList==null){
            return null;
        }
        return projectList.get(0);
    }
    
	@Override
	public Map<String, Object> getProjectLeader(String projectLeaderNo) {
		 String sql="select job_no from sys_user where bpm_user_id='"+projectLeaderNo +"'";
	        List<Map<String, Object>> projectList = primaryJdbcTemplate.queryForList(sql);
	        logger.info("人员信息返回值_________-"+projectList);
	        if(projectList.isEmpty()||projectList==null){
	            return null;
	        }
	        return projectList.get(0);
	}
}
